<?php

namespace App\Http\Controllers\Test;

use App\Http\Controllers\Controller;
use App\Models\Admin;

class ForUpdateController extends Controller
{

    // 简单的测试
    public function initialize()
    {
        parent::initialize();
    }

    // 查询一个
    // www.fudan.com/test/for-update/one
    public function one()
    {
        $model  = new Admin();
        $result = $model->where('id',2)->lockForUpdate()->first();

        return $this->success($result);
    }

    // 查询一个
    public function two()
    {
        $model  = new Admin();
        $result = $model->where('id',2)->lockForUpdate()->first();

        return $this->success($result);
    }

    // 查询一个
    public function three()
    {
        $model  = new Admin();
        $result = $model->where('id',2)->update(['mtime'=>LARAVEL_TIME]);

        return $this->success($result);
    }

}


